#include "declarations.h"
using namespace std;
void city::List()
{
	ifstream input;
	input.open("cities.txt");
	char a[100];
		while (input.good())
		{
			input.getline(a,99);
			std::cout<<a<<'\n';
		}
	input.close();
	return;
}
void city::Add()
{
	ofstream output;
	output.open("cities.txt",ofstream::app);
	char a[50];
	cout<<"Insert city name ";
	cin.getline(a,50);
	output<<a;
	output.close();
}
void city::Delete()
{
	cout<<"Delete city";
	char input[50];
	cin.getline(input,49);
	schedule b;
	if (b.CheckSchedule(input)!=-1) 
	{
			cout<<"error city used in a schedule";
			return;
	}
	ifstream instream;
	instream.open("cities.txt");
	ofstream outstream;
	outstream.open("cities1.txt",ofstream::app);
	char a[50];
	while (instream.good())
	{
		instream.getline(a,49);
		if (!strstr(a,input))
		{
			outstream<<a<<"\n";
		}
	}
	instream.close();
	outstream.close();
	remove("cities.txt");
	rename("cities1.txt","cities.txt");
}
	


city::city(void)
{
}


city::~city(void)
{
}
